#define _CRT_SECURE_NO_WARNINGS 520
#include<stdio.h>

int isleap_year(int year)
{
	if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
	{
		return 1;
	}
	return 0;
}


int day(int year, int month)
{
	int month_day[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	if (isleap_year(year)&&month == 2)
	{
		return 29;
	}
	else
	{
		return month_day[month];
	}
}



int main()
{
	int year = 0, month = 0;
	
	while (scanf("%d %d", &year, &month) != EOF)
	{
		int ans = day(year, month);
		printf("%d\n", ans);
	}
	return 0;
}